<?php
namespace app\overlord\model;

use app\BaseModel;
use think\facade\Db;

class Auth extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_overlord_store_auth';



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:04
     * @功能说明:内容添加
     */
    public function dataAdd($data){

        $data['create_time'] = time();

        $data['update_time'] = time();

        $res = $this->insert($data);

        return $res;

    }



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:05
     * @功能说明:内容编辑
     */
    public function dataUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:06
     * @功能说明:列表
     */
    public function dataList($dis,$page){

      $data = $this->alias('a')
              ->join('longbing_card_restaurant_store b','a.store_id = b.id')
              ->where($dis)
              ->field('a.*,b.title,b.store_type')
              ->group('a.id')
              ->order('a.id desc')
              ->paginate($page)
              ->toArray();

//      if(!empty($data['data'])){
//
//          foreach ($data['data'] as &$v){
//
//              $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
//          }
//      }

      return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:43
     * @功能说明:
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }












}